
package templateswing;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * @author Jean-Paul
 * <a href="mailto:evegeniy@gmail.com"><address>evegeniy@gmail.com</address></a>
 * @version 1.0 (beta)
 */

public class Main {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
	    public void run() {
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
    protected static MainFrame frame=new MainFrame();
}

class MainFrame extends JFrame {
    public MainFrame() {
        setSize(defaultWidth, defaultHeight);
        setTitle(defaultTitle);
        setLayout(new BorderLayout());

        setJMenuBar(menuBar);
        add(mainPanel);
    }
    
    protected int defaultWidth=640;
    protected  int defaultHeight=480;
    protected String defaultTitle="Frame Title";

    protected MainMenuBar menuBar=new MainMenuBar();
    protected MainPanel mainPanel=new MainPanel();
}

class MainMenuBar extends JMenuBar {
    public MainMenuBar() {
        add(fileMenu);
        fileMenu.add(openFileMenuItem);
        openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(
                'O', InputEvent.CTRL_DOWN_MASK));
        fileMenu.add(saveFileMenuItem);
        saveFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(
                'S', InputEvent.CTRL_DOWN_MASK));
        saveFileMenuItem.setEnabled(false);
        fileMenu.add(exitFileMenuItem);
        exitFileMenuItem.addActionListener(new ExitAction());
        exitFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(
                'E', InputEvent.CTRL_DOWN_MASK));

        add(helpMenu);
        helpMenu.add(aboutHelpMenu);
        aboutHelpMenu.addActionListener(new AboutAction());
    }
    JMenu fileMenu=new JMenu("Файл");
    JMenuItem openFileMenuItem=new JMenuItem("Открыть");
    JMenuItem exitFileMenuItem=new JMenuItem("Выход");
    JMenuItem saveFileMenuItem=new JMenuItem("Сохранить");
    JMenu helpMenu=new JMenu("Помощь");
    JMenuItem aboutHelpMenu=new JMenuItem("О программе");
}

class MainPanel extends JPanel {
    public MainPanel() {
        setBorder(BorderFactory.createLineBorder(Color.GREEN));
        setLayout(new BorderLayout());
        add(cp, BorderLayout.NORTH);
        add(radio, BorderLayout.SOUTH);
        add(combo, BorderLayout.WEST);

    }
    protected ChecksPanel cp=new ChecksPanel();
    protected RadioCheck radio=new RadioCheck();
    protected ComboBoxPanel combo=new ComboBoxPanel();
}

class ExitAction implements ActionListener{
    public void actionPerformed(ActionEvent event){
        System.exit(0);
    }
}

class AboutAction implements ActionListener {
    public void actionPerformed(ActionEvent event) {
        JOptionPane.showMessageDialog(
                Main.frame,
                "Простой шаблон программы с графическим интерфейсом \n"
                + "<html><i>&copy;" +" 2011 Jean-Paul</i></html>", "О Программе...",
                JOptionPane.INFORMATION_MESSAGE);
    }
}
